<template>
  <div>
    <TopFilter
      :list="topFilterList"
      :cols="3"
      @filterChange="changeHandle"
    ></TopFilter>

    <FilterTable
      ref="table"
      height="auto"
      :columns="columns"
      columnsRef="testindex"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onRowSelectChange="selectChangeHandle"
      :onColumnsChange="columns => this.columns = columns"
    >
    </FilterTable>

    <div style="height:47px;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer(1)">关 闭</el-button>
      <el-button @click="closeDrawer(2)" type="primary">确 定</el-button>
    </div>
  </div>
</template>

<script>
import {getAddQuestion} from '@/api/questionManage/question';
import { dictionary } from '@/utils/dictMixin';
export default {
  name: "partOrder",
  mixins: [dictionary],
  props:{
    value: {
      wxwjsy: Object
    },
  },
  data(){
    return{
      topFilterList: this.createdFrom(),
      fetchParams: {},
      columns:this.createdTable(),
      fetchApi: getAddQuestion,
      selectList: []
    }
  },
  created() {
    this.fetchParams=Object.assign({
      wxwjsy: this.value.wxwjsy,
      wxsfqy: 10031001
    },this.fetchParams)
  },
  mounted() {
    // 分页
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  methods:{
    createdFrom(){
      return [
        {
          type: 'INPUT',
          label: '问题代码',
          fieldName: 'wxwtdm'
        },
        {
          type: 'INPUT',
          label: '问题内容',
          fieldName: 'wxwtnr'
        }
      ]
    },
    createdTable() {
      return [
        {
          title: '序',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '问题代码',
          dataIndex: 'wxwtdm',
          sorter: true
        },
        {
          title: '问题内容',
          dataIndex: 'wxwtnr',
          sorter: true,
        },
        {
          title: '启用标记',
          dataIndex: 'wxsfqy',
          sorter: true,
          render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.wxsfqy, '1003')}</span>;
          }
        },
        {
          title: '问题类型',
          dataIndex: 'wxwtlx',
          sorter: true,
          render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.wxwtlx, '5018')}</span>;
          }
        },
        {
          title: '问题适用',
          dataIndex: 'wxwjsy',
          sorter: true,
          render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.wxwjsy, '5019')}</span>;
          }
        }
        // {
        //   type: 'SELECT',
        //   label: '问题类型',
        //   fieldName: 'wxwtlx',
        //   placeholder: '请选择',
        //   itemList: this.createDictList('5018')
        // },
        // {
        //   type: 'SELECT',
        //   label: '问题适用',
        //   fieldName: 'wxwjsy',
        //   placeholder: '请选择',
        //   itemList: this.createDictList('5019')
        // },
      ]
    },
    changeHandle(val){
      this.fetchParams=Object.assign({},this.fetchParams,val)
    },
    closeDrawer(type){
      if(type==1){
        this.$emit('close')
      }else{
        if (this.selectList !== null && this.selectList !== [] && this.selectList !== undefined && this.selectList.length > 0) {
          let arr = this.selectList;
          this.$emit('selectedOrder',arr)
        } else {
          this.$notify.error({ title: '提示信息', message: '请至少选择一条数据' || '操作失败!' });
        }
      }
    },
    selectChangeHandle(val){
      this.selectList=val;
    }
  }
}
</script>
